package cn.falconnect.adserver.adapter.persistence.dao;

import cn.falconnect.adserver.domain.ad.AppUser;
import org.apache.ibatis.annotations.MapKey;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Component;

import java.util.List;
import java.util.Map;

/**
 * @author dongbin.yu
 * @from 2016-06-06
 * @since V1.0
 */
@Component
public interface AppUserDao {

    @Results(value = {
            @Result(column = "app_id", property = "appId", id = true),
            @Result(column = "app_key", property = "appKey"),
            @Result(column = "status", property = "status"),
            @Result(column = "create_time", property = "createTime"),
            @Result(column = "update_time", property = "updateTime")
    })
    @Select("select app_id,app_key,status,create_time,update_time from app_user")
    List<AppUser> findAll();

    @Results(value = {
            @Result(column = "app_id", property = "appId", id = true),
            @Result(column = "app_key", property = "appKey"),
            @Result(column = "status", property = "status"),
            @Result(column = "create_time", property = "createTime"),
            @Result(column = "update_time", property = "updateTime")
    })
    @Select("select app_id,app_key,status,create_time,update_time from app_user")
    @MapKey("appId")
    Map<String, AppUser> findMapUser();

}
